//
//  LZSAboutViewController.m
//  IOSProject
//
//  Created by lzs on 2018/4/18.
//  Copyright © 2018年 com.linzhisheng. All rights reserved.
//

#import "LZSAboutViewController.h"

@interface LZSAboutViewController ()

@property (nonatomic, strong) UIImageView *iconView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *versionLabel;

@property (nonatomic, strong) UILabel *phoneLabel;
@property (nonatomic, strong) UILabel *phoneNumberLabel;
@property (nonatomic, strong) UIImageView *lineImageView;

@property (nonatomic, strong) UILabel *webLabel;
@property (nonatomic, strong) UILabel *websiteLabel;
@property (nonatomic, strong) UIImageView *lineImageView1;

@property (nonatomic, strong) UILabel *companyLabel;
@property (nonatomic, strong) UILabel *companydetailLabel;
@property (nonatomic, strong) UIImageView *lineImageView2;
@end

@implementation LZSAboutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.edgesForExtendedLayout = 0;
    self.title = @"商务合作";
    
    self.iconView = [[UIImageView alloc] init];
    self.iconView.backgroundColor = [UIColor redColor];
    [self.view addSubview:self.iconView];
    [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.top.equalTo(self.view).mas_offset(40);
        make.size.mas_equalTo(CGSizeMake(120, 120));
    }];
    
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.text = @"彩票资讯";
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.titleLabel.textColor = [UIColor colorWithHexString:@"#323232"];
    self.titleLabel.font = [UIFont systemFontOfSize:30];
    
    [self.view addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.top.equalTo(self.iconView.mas_bottom).mas_offset(30);
    }];
    
    
    self.versionLabel = [[UILabel alloc] init];
    self.versionLabel.text = @"版本:1.0.0 ";
    self.versionLabel.textAlignment = NSTextAlignmentCenter;
    self.versionLabel.textColor = [UIColor colorWithHexString:@"#323232"];
    self.versionLabel.font = [UIFont systemFontOfSize:20];
    
    [self.view addSubview:self.versionLabel];
    [self.versionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.top.equalTo(self.titleLabel.mas_bottom).mas_offset(30);
    }];
    
    
    self.phoneLabel = [[UILabel alloc] init];
    self.phoneLabel.text = @"联系电话:";
    self.phoneLabel.textAlignment = NSTextAlignmentCenter;
    self.phoneLabel.textColor = [UIColor colorWithHexString:@"#323232"];
    self.phoneLabel.font = [UIFont systemFontOfSize:16];
    
    self.phoneNumberLabel = [[UILabel alloc] init];
    self.phoneNumberLabel.text = @"0592-3709288";
    self.phoneNumberLabel.textAlignment = NSTextAlignmentCenter;
    self.phoneNumberLabel.textColor = [UIColor colorWithHexString:@"#be3737"];
    self.phoneNumberLabel.font = [UIFont systemFontOfSize:16];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(PhoneCall)];
    [self.phoneNumberLabel addGestureRecognizer:tap];
    self.phoneNumberLabel.userInteractionEnabled = YES;
    self.lineImageView = [[UIImageView alloc] init];
    
    
    self.webLabel = [[UILabel alloc] init];
    self.webLabel.text = @"客服邮箱";
    self.webLabel.textAlignment = NSTextAlignmentCenter;
    self.webLabel.textColor = [UIColor colorWithHexString:@"#3a3a3a"];
    self.webLabel.font = [UIFont systemFontOfSize:16];
    
    self.websiteLabel = [[UILabel alloc] init];
//    self.websiteLabel.text = @"http://g.wodegame.com";
    self.websiteLabel.text = @"942737012@qq.com";
    self.websiteLabel.textAlignment = NSTextAlignmentCenter;
    self.websiteLabel.textColor = [UIColor colorWithHexString:@"#4a9dff"];
    self.websiteLabel.font = [UIFont systemFontOfSize:16];
//    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(openWb)];
//    [self.websiteLabel addGestureRecognizer:tap1];
//    self.websiteLabel.userInteractionEnabled = YES;
    
    self.lineImageView1 = [[UIImageView alloc] init];
    
    self.companyLabel = [[UILabel alloc] init];
    self.companyLabel.text = @"地址:";
    self.companyLabel.textAlignment = NSTextAlignmentCenter;
    self.companyLabel.textColor = [UIColor colorWithHexString:@"#2a2a2a"];
    self.companyLabel.font = [UIFont systemFontOfSize:16];
    
    
    self.companydetailLabel = [[UILabel alloc] init];
    self.companydetailLabel.text = @"厦门市软件园二期观日路";
    self.companydetailLabel.textAlignment = NSTextAlignmentCenter;
    self.companydetailLabel.textColor = [UIColor colorWithHexString:@"#9c9c9c"];
    self.companydetailLabel.font = [UIFont systemFontOfSize:16];
    
    self.lineImageView2 = [[UIImageView alloc] init];
    
    [self.view addSubview:self.phoneLabel];
    [self.view addSubview:self.phoneNumberLabel];
    [self.view addSubview:self.lineImageView];
    
    [self.view addSubview:self.webLabel];
    [self.view addSubview:self.websiteLabel];
    [self.view addSubview:self.lineImageView1];
    
    [self.view addSubview:self.companyLabel];
    [self.view addSubview:self.companydetailLabel];
    [self.view addSubview:self.lineImageView2];
    
    [self.phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.versionLabel.mas_bottom).mas_offset(30);
        make.left.equalTo(self.view).mas_offset(15);
        make.right.equalTo(self.view);
    }];
    
    [self.phoneNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.phoneLabel.mas_bottom).mas_offset(10);
        make.left.right.equalTo(self.phoneLabel);
    }];
    
    [self.lineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.phoneNumberLabel.mas_bottom).mas_offset(10);
        make.left.right.equalTo(self.phoneNumberLabel);
        make.height.mas_equalTo(5);
    }];
    
    
    [self.webLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lineImageView.mas_bottom).mas_offset(10);
        make.left.right.equalTo(self.phoneNumberLabel);
    }];
    
    [self.websiteLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.webLabel.mas_bottom).mas_offset(10);
        make.left.right.equalTo(self.phoneNumberLabel);
    }];
    
    [self.lineImageView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.websiteLabel.mas_bottom).mas_offset(10);
        make.left.right.equalTo(self.phoneNumberLabel);
        make.height.mas_equalTo(5);
    }];
    
    [self.companyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lineImageView1.mas_bottom).mas_offset(10);
        make.left.right.equalTo(self.phoneNumberLabel);
    }];
    
    [self.companydetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.companyLabel.mas_bottom).mas_offset(10);
        make.left.right.equalTo(self.phoneNumberLabel);
    }];
    
    [self.lineImageView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.companydetailLabel.mas_bottom).mas_offset(10);
        make.left.right.equalTo(self.phoneNumberLabel);
        make.height.mas_equalTo(5);
    }];
    
    
    
}

#pragma mark===================拨打电话=============
-(void)PhoneCall{
    NSMutableString *str2=[[NSMutableString alloc] initWithFormat:@"tel:%@",self.phoneNumberLabel.text];
    
    NSLog(@"%@",str2);
    
    UIWebView * callWebview = [[UIWebView alloc] init];
    
    [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str2]]];
    
    [self.view addSubview:callWebview];
}

#pragma mark=======================链接跳转======================
-(void)openWb{
    NSString *url = self.websiteLabel.text;//把http://带上
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}

-(void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    self.lineImageView.image = [self drawLineOfDashByImageView:self.lineImageView];
    
    self.lineImageView1.image = [self drawLineOfDashByImageView:self.lineImageView1];
    
    self.lineImageView2.image = [self drawLineOfDashByImageView:self.lineImageView2];
}


- (UIImage *)drawLineOfDashByImageView:(UIImageView *)imageView {
    // 开始划线 划线的frame
    UIGraphicsBeginImageContext(imageView.frame.size);
    
    [imageView.image drawInRect:CGRectMake(0, 0, imageView.frame.size.width, imageView.frame.size.height)];
    
    // 获取上下文
    CGContextRef line = UIGraphicsGetCurrentContext();
    
    // 设置线条终点的形状
    CGContextSetLineCap(line, kCGLineCapRound);
    // 设置虚线的长度 和 间距
    CGFloat lengths[] = {2,3};
    
    CGContextSetStrokeColorWithColor(line, [UIColor colorWithHexString:@"#cecece"].CGColor);
    // 开始绘制虚线
    CGContextSetLineDash(line, 0, lengths, 2);
    
    CGContextMoveToPoint(line, 0.0, 2.0);
    
    CGContextAddLineToPoint(line, 300, 2.0);
    
    CGContextStrokePath(line);
    
    return UIGraphicsGetImageFromCurrentImageContext();
}

@end
